package com.ds.lens.data.service.dao.sql.provider;

import com.ds.lens.data.service.dao.entity.LensUserRoleRelation;
import org.apache.ibatis.jdbc.SQL;

public class LensUserRoleRelationSqlProvider {

    public String insertSelective(LensUserRoleRelation record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lens_user_role_relation");

        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getUserName() != null) {
            sql.VALUES("user_name", "#{userName,jdbcType=VARCHAR}");
        }

        if (record.getRoleId() != null) {
            sql.VALUES("role_id", "#{ruleId,jdbcType=BIGINT}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LensUserRoleRelation record) {
        SQL sql = new SQL();
        sql.UPDATE("lens_user_role_relation");

        if (record.getUserName() != null) {
            sql.SET("user_name = #{userName,jdbcType=VARCHAR}");
        }

        if (record.getRoleId() != null) {
            sql.SET("role_id = #{ruleId,jdbcType=BIGINT}");
        }

        sql.WHERE("id = #{id,jdbcType=BIGINT}");

        return sql.toString();
    }
}
